import { createRouter, createWebHistory } from 'vue-router'
import store from '@/store'


const router = createRouter({
    history: createWebHistory(import.meta.env.BASE_URL),
    routes: [
        {
            path: '/welcome',
            name: 'welcome',
            redirect: '/welcome/welcome-login',
            component: () => import('@/pages/WelComePage.vue'),
            meta: {
                requiresLogin: true,
                title: '登录'
            },
            children:[
                {
                    path: 'welcome-login',
                    name: 'welcome-login',
                    component: () => import('@/components/WelCome/LoginPage.vue'),
                },
                {
                    path: "welcome-register",
                    name: "welcome-register",
                    component:() => import ("@/components/WelCome/RegisterPage.vue")
                }
            ]
        },
        {
            path: '/',
            name: 'HomePage',
            redirect: '/square',
            component: () => import('@/pages/HomePage.vue'),
            mata: { title: '首页' },
            children:[
                {
                    path: '/square',
                    name: 'Square',
                    component: () => import('@/components/Content/Square.vue')
                },
                {
                    path: '/elite',
                    name: 'Elite',
                    component: ()=>import('@/components/Content/Elite.vue')
                },
                {
                    path: '/tech',
                    name: 'Tech',
                    component:()=>import('@/components/Content/Tech.vue')
                },
                {
                    path: '/life',
                    name: 'Life',
                    component:()=>import('@/components/Content/Life.vue')
                },
                {
                    path: '/acg',
                    name: 'ACG',
                    component:()=>import('@/components/Content/ACG.vue')
                },
                {
                    path: '/study',
                    name: 'Study',
                    component:()=>import('@/components/Content/Study.vue')
                },
            ]
        },
        {
            path:'/person',
            name:'person',
            redirect: '/person/Person-Card',
            mata: { title: '个人页面' },
            component:()=>import('@/pages/PersonalPage.vue'),
            children:[
                {
                    path: 'Person-Card',
                    name: 'Person-Card',
                    redirect: '/person/Person-Card/UserDetail', // 将路由重定向到 UserDetail
                    component:()=>import('@/components/Person/PersonalCard.vue'),
                    children:[
                        {
                            path: 'UserDetail',
                            name: 'Person-Card-UserDetail',
                            component:() => import('@/components/Person/UserButtonCard.vue')
                        },
                        {
                            path: 'AdminDetail',
                            name: 'Person-Card-AdminDetail',
                            component:() => import('@/components/Person/AdminButtonCard.vue')
                        }
                    ]
                },
                {
                    path: 'Person-change-Profile',
                    name: 'Person-change-Profile',
                    component:()=>import('@/components/Person/ProfileChange.vue'),
                },
                {
                    path: 'changePassWord',
                    name: 'Change-passWord',
                    component:()=>import('@/components/Person/changePassword.vue')
                },
                {
                    path: 'Person-Edit',
                    name: 'Person-Edit',
                    component:()=>import('@/pages/PersonEditPage.vue')
                }
            ],
            meta: {
                requiresAuth: true
            }
        },
        {
            path: '/article',
            name: 'article',
            mata: { title: '文章' },
            component:() => import('@/pages/ArticlePage.vue')
        },
        {
            path: '/edit',
            name: 'edit',
            mata: { title: '编辑' },
            component:() => import('@/pages/EditPage.vue'),
            meta: {
                requiresAuth: true
            }
        },
        {
            path: '/admin',
            name: 'admin',
            mata: { title: '管理' },
            component:() => import('@/pages/Manage.vue'),
            meta: {
                requiresAdmin: true
            }
        },
        {
            path: '/edit-article',
            name:'EditArticle',
            mata: { title: '修改' },
            component:()=>import('@/pages/PersonEditPage.vue')
        },
    ]
})

export default router
